package bb.lanxing.lib.devices.ble.ble.characteristic;

import kotlin.jvm.internal.DefaultConstructorMarker;

public enum BatteryStatus {
    Reserved((short)0),
    Full((short)1),
    Good((short)2),
    Middle((short)3),
    Low((short)4),
    Critical((short)5),
    Charging((short)6);
    
    public static final Companion Companion = new Companion(null);
    private final short value;

    BatteryStatus(short s) {
        this.value = s;
    }

    public final short getValue() {
        return this.value;
    }

    public static final class Companion {
        public Companion(DefaultConstructorMarker defaultConstructorMarker) {
            this();
        }

        private Companion() {
        }

        public BatteryStatus from(Byte b) {
            BatteryStatus batteryStatus;
            BatteryStatus[] values = BatteryStatus.values();
            int length = values.length;
            int i = 0;
            while (true) {
                if (i >= length) {
                    batteryStatus = null;
                    break;
                }
                batteryStatus = values[i];
                if (b != null && ((byte) batteryStatus.getValue()) == b.byteValue()) {
                    break;
                }
                i++;
            }
            return batteryStatus == null ? BatteryStatus.Reserved : batteryStatus;
        }
    }
}
